{extend name="lib/common_list" /}
{block name="title"}新增用户{/block}
{block name="css"}
    <link rel="stylesheet" href="/static/sys/css/common.css">
{/block}
{block name="javascript"}
    <script>
         $(document).ready(function () {
            $("#ok").bind("click", Save);
            $("#cancel").bind("click", function () {
                parent.layer.close(parent.layer_add_index);
            });
         })

         function Save() {
            var username = $.trim($("input[name=user_name]").val());
            if (username.length == 0) {                
                layer.tips('登录帐号不能为空！', 'input[name=user_name]', { tips: [2, '#78BA32'] });
                return false;
            }
            var password = $.trim($("input[name=pass_word]").val());
            if (password.length == 0) {
                layer.tips('登录密码不能为空！', 'input[name=pass_word]', { tips: [2, '#78BA32'] });
                return false;
            }
            var realName = $.trim($("input[name=real_name]").val());
            if (realName.length == 0) {                
                layer.tips('真实名称不能为空！', 'input[name=real_name]', { tips: [2, '#78BA32'] });
                return false;
            }
           
            var load_index = layer.load(0, { shade: false });
            $.ajax({
                type: "post",
                url: "{:url('manager/add')}?t=" + new Date(),
                data: $("form").serialize(),
                dataType: "json",
                success: function (result) {
                    layer.close(load_index);
                    if (result.code == 0) {
                        layer.alert('添加成功！', function () {
                            if (typeof (parent.initTable) == "function")
                                parent.initTable();
                            parent.layer.close(parent.layer_add_index)
                        });
                    } else {
                        layer.alert(result.msg);
                    }
                },
                error:function(xhr,textStatus){
                    layer.close(load_index);
                    layer.alert('服务器繁忙！');
                }
            });
        }
    </script>
{/block}
{block name="content"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form method="post" id="fmNew" class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><i class="icon-asterisk">*</i>登录帐号：</label>
                            <div class="col-sm-8">
                                <input type="text" id="txtusername" name="user_name" class="form-control" spellcheck="false" placeholder="登录帐号">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><i class="icon-asterisk">*</i>登录密码：</label>
                            <div class="col-sm-8">
                                <input type="password" name="pass_word" class="form-control" placeholder="登录密码">
                            </div>
                        </div>                       
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><i class="icon-asterisk">*</i>真实名称：</label>
                            <div class="col-sm-8">
                                <input type="text" name="real_name" id="real_name" class="form-control" placeholder="用户名">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">状态：</label>
                            <div class="col-sm-2">
                                <select class="form-control m-b" name="status">
                                    <option value="0">启用</option>
                                    <option value="1">禁用</option>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-12" style="text-align:center;">
                                <button class="btn btn-primary" id="ok" type="button">提交</button>
                                <button class="btn btn-white" id="cancel" type="button">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>        
{/block}
